Adding Alternating Background Color
To create a report with alternating background color, use the C1.C1Report.Section.OnPrint property of the Detail section to change the C1.C1Report.Section.BackColor property of the section.
To do this, complete the following steps:
-
Open the C1ReportDesigner application. For more information on how to access C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
-
Create a new report|tag=Creating a Basic Report Definition or open an existing report. Once you have the report in the C1ReportDesigner application, you can modify the report properties.
-
Click the Close Print Preview button to begin editing the report.
-
In Design mode, select the report from the drop-down list above the Properties window.
-
Locate the C1.C1Report.C1Report.OnOpen property and enter cnt = 0. This initializes the cnt variable.
-
Next, select Detail from the drop-down list above the Properties window.
-
Locate the C1.C1Report.Section.OnPrint property and click the empty field next to it, and then click the ellipsis button.
-
The VBScrpit Editor appears. Enter the following VBScript expression in the code editor:
cnt = cnt + 1
if cnt mod 2 = 0 then
detail.backcolor = rgb(200,220,200)
else
detail.backcolor = rgb(255,255,255)
endif
-
Click the Preview button to preview the report with alternating background.
This topic illustrates the following:

The report will appear with an alternating background color.
Whenever a Detail section is rendered, the counter is incremented and the BackColor property of the Detail section is toggled.
Sample Report Available:
For the complete report, see report "01: Alternating Background (Greenbar report)" in the CommonTasks.xml report definition file, which is available for download from the CommonTasks sample on the ComponentOne HelpCentral Sample page.